package com.itheima.easy.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 消息队列配置类
 *
 **/
//@Configuration
public class DirectRabbitConfig {

    /**
     * 队列
     * @return
     */
    //@Bean
    public Queue tradeQueue(){
        return new Queue("trade-queue",true);
    }

    /**
     * 交换机
     * @return
     */
    //@Bean
    public DirectExchange tradeDirectExchange(){
        return new DirectExchange("trade-exchange",true,false);
    }

    /**
     * 绑定交换机和队列
     * @return
     */
    //@Bean
    public Binding tradeBinding(){
        return BindingBuilder.bind(tradeQueue()).to(tradeDirectExchange()).with("trade-key");
    }
}
